/* 
    处理运算, 加, 减, 还原
*/

import { ActionType } from "../action-types";
import { Action } from "../actions";
const initialState = 0;

const reducer = (state: number = initialState, action: Action) => {
  switch (action.type) {
    case ActionType.ADDITION:
      return state + action.payload;
    case ActionType.SUBTRACTION:
      return state - action.payload;
    case ActionType.RESTORE:
      return initialState;
    default:
      return state;
  }
};

export default reducer;
